package com.myfum.wingplayer.utils
{
	import com.myfum.wingplayer.entity.ScheduledContentData;
	import com.myfum.wingplayer.interfaces.IContentIterator;
	
	public class ContentIterator implements IContentIterator
	{
		public function ContentIterator(src:Array)
		{
			_collection = src;
		}
		
		private var _collection:Array;
		private var _index:int = 0;
		
		public function next():ScheduledContentData
		{
			var data:ScheduledContentData = _collection[_index];
			_index++;
			return data;
		}
		
		public function prepare():ScheduledContentData
		{
			if(hasNext()){
				return _collection[_index];
			}else{
				if(length>0){
					return _collection[0];
				}else{
					return null;
				}
			}
		}
		
		public function get index():int
		{
			return _index;
		}
		
		public function hasNext():Boolean
		{
			return index < _collection.length;
		}
		
		public function reset():void
		{
			_index = 0;
		}
		
		public function get length():int{
			if(_collection)return _collection.length;
			else return 0;
		}
	}
}